package com.wyl.mobileplayer.ui.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.text.format.DateUtils;
import android.text.format.Formatter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wyl.mobileplayer.R;
import com.wyl.mobileplayer.model.bean.Media;

import java.util.List;

/**
 * 时间：2018/6/26 0026 11:16
 * 描述：本地视频的适配器
 * 修改人：
 * 修改时间：
 * 修改备注：
 *
 * @author WangYoule
 * @qq 270628297
 */
public class MediaAdapter extends BaseQuickAdapter<Media, BaseViewHolder> {
    private Context context;


    public MediaAdapter(Context context, @Nullable List<Media> data) {
        super(R.layout.item_media, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, Media item) {
        String duration = DateUtils.formatDateRange(context, 0L, item.duration, 0);
        helper.setText(R.id.tv_display_name, item.display_name)
                .setText(R.id.tv_duration, duration)
                .setText(R.id.tv_size, Formatter.formatFileSize(context, item.size));
    }

}